package com.auxgroup.hr.front.site.co.process;

import java.util.List;
import java.util.Set;

import javax.annotation.Resource;

import com.auxgroup.hr.front.site.co.BaseWfCO;
import com.auxgroup.hr.front.site.inteceptor.SessionGain;
import com.auxgroup.hr.front.site.vo.process.WfDmcHdrRespVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.auxgroup.hr.front.commons.vo.BaseResponseVO;
import com.auxgroup.hr.front.commons.vo.UserDTO;
import com.auxgroup.hr.front.dao.domain.PsCAppStepInst;
import com.auxgroup.hr.front.dao.domain.PsCWfDmcDtl;
import com.auxgroup.hr.front.dao.domain.PsCWfDmcHdr;
import com.auxgroup.hr.front.dozer.IObjectMapper;
import com.auxgroup.hr.front.service.process.ProcessService;
import com.auxgroup.hr.front.service.process.WfDmcDtlService;
import com.auxgroup.hr.front.service.process.WfDmcHdrService;
import com.auxgroup.hr.front.service.process.WfFileService;
import com.auxgroup.hr.front.site.co.BaseCO;
import com.auxgroup.hr.front.site.inteceptor.SessionGain;
import com.auxgroup.hr.front.site.vo.process.WfDmcHdrRespVO;

/**
 * 离职补偿金流程
 * @author wangchangyun
 * @version 创建时间：180601 
 */
@RestController
@RequestMapping("${auxgroup.hr.contextPath}/wfDmcHdr")
public class WfDmcHdrCO extends BaseWfCO {

	private static final Logger logger = LoggerFactory.getLogger(WfDmcHdrCO.class);

	@Autowired
	public WfDmcHdrService wfDmcHdrService;
	
	@Resource(name = "dozerMapper")
	protected IObjectMapper objectMapper;

	
	@Autowired
	private WfDmcDtlService wfDmcDtlService;
	
	/**
	 * 获取离职补偿金流程详情
	 * @return
	 */
	@GetMapping(value = "/getDmcInfo")
	public BaseResponseVO getOne(String cTransactionNbr,@SessionGain("user") UserDTO user) {
		logger.info("getWfDmcHdr param= {}", cTransactionNbr);
		PsCWfDmcHdr wfDmcHdr = wfDmcHdrService.getWfDmcHdr(cTransactionNbr);
		if (wfDmcHdr == null) {
			return buildRespone(new Object());
		}
		WfDmcHdrRespVO respVo = objectMapper.map(wfDmcHdr, WfDmcHdrRespVO.class);
		List<PsCWfDmcDtl> dtls = wfDmcDtlService.getAll(cTransactionNbr);
		respVo.setDmcDtls(dtls);
		fillBaseWfInfo(user, wfDmcHdr, respVo);
		return buildRespone(respVo);
	}

	@Override
	protected Set<String> getAuthFileds() {
		return null;
	}
}
